<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
    <div id="app">
        <!--虚拟dom放在内存，出于性能考虑尽可能复用已经存在的dom 添加key避免复用-->
        <span v-if="isEmail">
    <!--for聚焦-->
    <label for="email">用户邮箱</label>
    <input type="text" id="email" placeholder="用户邮箱" key="email">
  </span>
        <span v-else>
    <label for="username">用户账号</label>
    <input type="text" id="username" placeholder="用户账号" key="username">
  </span>
        <button @click="loginChange">切换登录方式</button>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                isEmail: true,
            },
            methods: {
                loginChange() {
                    this.isEmail = !this.isEmail
                }
            }
        })
    </script>
</body>

</html>